import React from "react";
import { Avatar, List, Dialog, Toast } from "antd-mobile";
import "./index.scss";
import { historyShape, storeShape } from "src/propType";

function PersonCenter(props) {
    const { name = "", projName = "" } = props.store.user.userData;

    const logout = async () => {
        const isOut = await Dialog.confirm({ content: "是否退出登录?" });
        if (!isOut) return;
        props.store.user.logout().then(res => {
            if (res.code === 200) {
                Toast.show({ content: "退出登录成功!" });
                props.history.replace("/login");
            }
        });
    };

    return (
        <div className="me">
            <List>
                <List.Item prefix={<Avatar src="" />} description={projName}>
                    {name}
                </List.Item>
            </List>
            <div style={{ height: "200px" }}></div>
            {/* <List>
                <List.Item onClick={logout}>退出登录</List.Item>
            </List> */}
        </div>
    );
}

PersonCenter.propTypes = {
    store: storeShape,
    history: historyShape,
};

export default PersonCenter;
